<!--等级评价机构-->
<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>等级评价机构</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="option-box">
      <span>机构名称：<el-input size="small" style="width: 12%;" placeholder="请输入" /></span>
      <el-button type="primary" size="small" @click="">搜索</el-button>
      <el-button size="small" @click="">重置</el-button>
    </div>
    <div class="addTc">
      <el-button type="primary" @click="addTc">+创建机构</el-button>
    </div>
    <hr>
    <el-table size="small" :data="tableDate" border style="width: 100%">
      <el-table-column label="序号" type="index" align="center"></el-table-column>
      <el-table-column prop="pjjgb_name" label="机构名称" width="610px" />
      <el-table-column prop="create_time" label="创建时间" width="400px">
        <template v-slot="scope">
          {{ formatDate(scope.row.create_time) }}
        </template>
      </el-table-column>
      <el-table-column prop="user_code" label="操作" width="400px">
        <template v-slot="scope">
          <el-button size="mini" type="danger" @click="evaEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" @click="tcDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'
import { querypjjgblist } from '../../api/InstitutionApi'

export default defineComponent({
  name: "Management",
  data() {
    return {
      tableDate: [],// 列表存储具体数据
      isEdit: false,
    }
  },

  created() {
    // 获取机构等级评价
    this.getdata()
  },

  methods: {
    getdata() {
      querypjjgblist().then(res => {
        this.tableDate = res.data.base_info;
        console.log('等级评价：', res);
      })
    },
    // 删除等级评价
    tcDelete(index, row) {

    },
    // 编辑等级评价
    evaEdit(index, row) {
      // 方式3：带查询参数（显示在URL中）
      this.$router.push({
        path: '/levelEvaluation/levelEvaEdit',
        query: {'evarow': row }
      });
    },
    // 添加新的机构
    addTc() {
      // console.log('查看：',flowid)
      // 跳转页面的三种方式
      // 方式1：通过 path 跳转
      // this.$router.push({
      //   path: `/enterprises/EnEdit/:index`
      // });
      // 方式2：通过 name 跳转（推荐）
      // this.$router.push({
      //   name: 'enedit',
      //   params: { index: index }
      // });

      // 方式3：带查询参数（显示在URL中）
      this.$router.push({
        path: '/levelEvaluation/levelEvaEdit',
        query:''
      });
    },

    // 时间格式处理
    formatDate(DateTime) {
      // 1. 将字符串转为 Date 对象
      const date = new Date(DateTime);
      // 2. 提取年、月、日（注意月份要 +1）
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, '0'); // 补零
      const day = String(date.getDate()).padStart(2, '0');      // 补零
      const hours = String(date.getHours()).padStart(2, '0');
      const minutes = String(date.getMinutes()).padStart(2, '0');
      const seconds = String(date.getSeconds()).padStart(2, '0');

      // 3. 拼接成目标格式
      const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
      return formattedDate
    }


  },
})
</script>



<style scoped>
.option-box {
  margin-top: 1%;

  span {
    margin-left: 1%;
  }

  .el-button {
    width: 5%;
  }
}

.addTc {
  margin: 10px 0 ;
}

.el-table {
  margin-top: 1%;
}

.el-pagination {
  margin-top: 1%;
  float: right;
}
</style>
